﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public static class SubStringInSBuilder
{

    //Implement an extension method Substring(int index, int length) 
    //for the class StringBuilder that returns new StringBuilder 
    //and has the same functionality as Substring in the class String.

    public static StringBuilder Substring(this StringBuilder str, int index, int length)
    {
        StringBuilder newStr = new StringBuilder();
        for (int i = index; i < index+length; i++)
        {
            newStr.Append(str[i]);
        }
        return newStr;
    }
    static void Main()
    {
        StringBuilder myStr = new StringBuilder();
        myStr.Append("My name is Lachezar!!");
        Console.WriteLine(myStr.Substring(3, 2));

        StringBuilder test = new StringBuilder();
        test.Append("0123456789abcdef");
        Console.WriteLine(test.Substring(5,5));
    }
}